#!/bin/bash
sh check_expect.sh
#read -p "Delete username: " DNAME
#DNAME=$(echo $1)
DNAME=$1
docker run -v /home/openvpn/openvpn:/etc/openvpn --rm -it kylemanna/openvpn:2.4 easyrsa revoke $DNAME
expect <<EOF
set timeout 20
spawn docker run -v /home/openvpn/openvpn:/etc/openvpn --rm -it kylemanna/openvpn:2.4 easyrsa gen-crl
expect "ca.key"
send "12345678\n"
expect eof
EOF
#docker run -v /home/openvpn/openvpn:/etc/openvpn --rm -it kylemanna/openvpn:2.4 easyrsa gen-crl
docker run -v /home/openvpn/openvpn:/etc/openvpn --rm -it kylemanna/openvpn:2.4 rm -f /etc/openvpn/pki/reqs/"$DNAME".req
docker run -v /home/openvpn/openvpn:/etc/openvpn --rm -it kylemanna/openvpn:2.4 rm -f /etc/openvpn/pki/private/"$DNAME".key
docker run -v /home/openvpn/openvpn:/etc/openvpn --rm -it kylemanna/openvpn:2.4 rm -f /etc/openvpn/pki/issued/"$DNAME".crt
docker restart openvpn
